class Student:
    name = None
    age = None
    
    def __init__(self, name, age):
        self.age = age
        self.name = name
    
    # __str__ 默认返回<__main__.ClassName object at 0x内存地址>
    def __str__(self):
        return f"name:{self.name}, age:{self.age}"
    
    # __lt__ 小于的比较，写了默认大于也能比
    def __lt__(self, other):
        return self.age < other.age
    
    # __le__ 小于等于……
    def __le__(self, other):
        return self.age <= other.age
    
    # __eq__ 等于…… 默认比较两个内存地址判断是否为同一个对象， 重写这个功能，实现类似C++重载==的效果
    def __eq__(self, value):
        return self.age == value.age and self.name == value.name


stu_1 = Student("周杰伦", 31)
print(stu_1.__str__())
stu_2 = Student("林俊杰", 36)
stu_3 = Student("张三", 36)
stu_4 = Student("张三", 36)
print(stu_1 < stu_2, stu_1 > stu_2)
print(stu_1 <= stu_2, stu_1 >= stu_2)
print(stu_3 <= stu_2, stu_3 >= stu_2)
print(stu_3 == stu_4, stu_1 == stu_2)
